const app = getApp();
Component({

  properties: {
    parameter: {
      type: Object,
      value: {
        class: '0'
      }
    },
    opacity: {
      type: String,
      value: 0,
    },
    logoUrl: {
      type: String,
      value: ''
    },
    backFunc: {
      type: Function,
      value: null
    }
  },
  data: {
    navH: ''
  },
  ready: function () {
  },
  attached: function () {
    wx.getSystemInfo({
      success: (res) => {
        this.setData({
          navH: res.statusBarHeight * (750 / res.windowWidth) + 97
        })
      }, fail(err) {
      }
    });
  },
  methods: {
    goBack(e) {
      const backUrl = this.data.parameter.backUrl || '';
      let pages = getCurrentPages();
      let tabBarMenus = [
        'pages/activity/index',
        'pages/task/index',
        'pages/member/index',
      ];

      if (backUrl) {
        if (tabBarMenus.indexOf(backUrl) !== -1) { //
          wx.switchTab({url: backUrl});
        } else {
          wx.redirectTo({
            url: backUrl
          });
        }
      } else if (pages.length > 1) {
        wx.navigateBack()
      } else {
        wx.switchTab({
          url: '/pages/activity/index'
        })
      }
    },

  }
})
;
